package Web;

import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;

import Command.MainCommand;

public class RunWebThread extends Thread{
	
	private MainCommand mainCommand;
	public RunWebThread(MainCommand mainCommand) throws Exception{
		this.mainCommand=mainCommand;
	}
	
	public void run() {
		Server server = new Server(8080);
	     Context root = new Context(server,"/",Context.SESSIONS);
	     root.addServlet(new ServletHolder(new MainServlet()), "/*");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/time");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/time1");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/start_listener");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/end_listener");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/start_init");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/stop_init");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/pause_init");
	     root.addServlet(new ServletHolder(new ForeverFrameServlet(mainCommand)), "/search");
	     try {
			server.start();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	     try {
			server.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}


}
